"""
版本日志管理
"""
import pytest
from Config.Base import Base
from playwright.sync_api import Page, expect, Playwright
from Config.config import *
from Config.URL import *
import allure, os
from Config.Base import Base
from Config.Tool import tool


@pytest.mark.基础管理系统
@pytest.mark.系统管理
def test_case(playwright : Playwright) -> None:

    SetupTeardown = Base(playwright)
    SetupTeardown.goto(url)
    SetupTeardown.login(username_admin, password_admin)
    context = SetupTeardown.context
    page = SetupTeardown.page
    page.goto(url+url_login)
    page.get_by_placeholder("请输入用户名").fill(username_admin)
    page.get_by_placeholder("请输入密码").fill(password_admin)
    page.get_by_role("button", name="登 录").click()
    page.get_by_text("UAT-环北部湾广西水资源配置工程").first.click()
    page.wait_for_timeout(1000)
    page.goto(url+url_banbenrizhiguanli)

    page.get_by_role("button", name=" 新建").click()
    page.get_by_label("新建").get_by_placeholder("请输入版本名").fill("AutoTest版本1")
    page.get_by_placeholder("请选择发布时间").click()
    page.locator(".available > div > span").first.click()
    page.locator("pre").nth(1).click()
    page.locator("textarea").fill("内容1")
    page.get_by_role("button", name="确 定").click()
    expect(page.get_by_role("paragraph")).to_contain_text("新建成功！")
    page.get_by_role("button", name="发布").click()
    page.wait_for_timeout(3000)
    page.get_by_role("button", name="确定").click()
    expect(page.get_by_role("paragraph")).to_contain_text("发布成功")

    SetupTeardown.close()
